import request from '@/utils/request'

// 获取活动资讯分页列表
export function getNewsPage(params) {
  return request({
    url: '/api/admin/news/page',
    method: 'get',
    params
  })
}

// 获取活动资讯列表（不分页）
export function getNewsList(params) {
  return request({
    url: '/api/admin/news/list',
    method: 'get',
    params
  })
}

// 获取活动资讯详情
export function getNewsDetail(id) {
  return request({
    url: `/api/admin/news/${id}`,
    method: 'get'
  })
}

// 创建活动资讯
export function createNews(data) {
  return request({
    url: '/api/admin/news',
    method: 'post',
    data
  })
}

// 更新活动资讯
export function updateNews(id, data) {
  return request({
    url: `/api/admin/news/${id}`,
    method: 'put',
    data
  })
}

// 删除活动资讯
export function deleteNews(id) {
  return request({
    url: `/api/admin/news/${id}`,
    method: 'delete'
  })
}

// 批量删除活动资讯
export function batchDeleteNews(ids) {
  return request({
    url: '/api/admin/news/batch',
    method: 'delete',
    data: ids
  })
}

// 更新单个资讯状态
export function updateNewsStatus(id, status) {
  return request({
    url: `/api/admin/news/${id}/status`,
    method: 'put',
    params: { status }
  })
}

// 批量更新状态
export function batchUpdateNewsStatus(ids, status) {
  return request({
    url: '/api/admin/news/batch/status',
    method: 'put',
    data: { ids, status }
  })
}

// 获取统计信息
export function getNewsStats() {
  return request({
    url: '/api/admin/news/stats',
    method: 'get'
  })
}

// 类型选项
export const NEWS_TYPES = [
  { value: 1, label: '活动', type: 'primary' },
  { value: 2, label: '资讯', type: 'success' },
  { value: 3, label: '公告', type: 'warning' }
]

// 状态选项
export const NEWS_STATUS = [
  { value: 0, label: '草稿', type: 'info' },
  { value: 1, label: '已发布', type: 'success' },
  { value: 2, label: '已下架', type: 'warning' }
]
